﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using University.Workshop.Business;

namespace University.Workshop.Presenters.WaterReadingControl.Search
{
    public class PresenterSearchWaterReading
    {
        ISearchWaterReadingView view;

        public PresenterSearchWaterReading(ISearchWaterReadingView view)
        {
            this.view = view;
        }

        public void SearchByAllParameters()
        {
            try
            {
                Model.KardexHelper kardexHelper = new Model.KardexHelper() { Name = view.Name, LastName = view.LastName, Allotment = view.Allotment, Square = view.Square };
                //Model.WaterReadingControl waterReadingControl = new Model.WaterReadingControl(){  }
                view.wrList = ManagerWaterReadingControl.SearchByAllParameters(kardexHelper);
            }
            catch(Exception ex)
            {
                view.wrList = null;
                view.NotifyErrorMessage(ex.Message);
            }
        }

        public void ConfirmReadingsMade()
        {
            try
            {
                int numberReadings = ManagerWaterReadingControl.ConfirmReadingsMade();
                if (numberReadings == 1)
                    view.NotifySystemMessage("Se confirmo " + numberReadings + " lectura");
                else
                    view.NotifySystemMessage("Se confirmaron " + numberReadings + " lecturas");
            }
            catch (Exception ex)
            {
                view.NotifyErrorMessage(ex.Message);
            }
        }
    }
}
